﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;

namespace QLKS
{
    public partial class frmXemDanhSachHoaDonTrongThang : Form
    {
        public frmXemDanhSachHoaDonTrongThang()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnXemDanhSach_Click(object sender, EventArgs e)
        {
            lvDSHoaDon.Items.Clear();

            DataTable dt = HoaDonBUS.LayDanhSachHoaDonTheoThang(int.Parse(cbbThang.Text), int.Parse(cbbNam.Text));

            foreach (DataRow dr in dt.Rows)
            {
                ListViewItem lv = new ListViewItem(dr["MaHoaDon"].ToString());

                for (int i = 1; i < dt.Columns.Count; i++)
                {
                    lv.SubItems.Add(dr[i].ToString());
                }
                lvDSHoaDon.Items.Add(lv);
            }
            float tongDoanhThu = 0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                tongDoanhThu = tongDoanhThu + float.Parse(dr["TriGia"].ToString());
            }
            txtDoanhThu.Text = tongDoanhThu.ToString();
        }

        private void lvDSHoaDon_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void frmXemDanhSachHoaDonTrongThang_Load(object sender, EventArgs e)
        {
            for (int i = 1; i <= 12; i++)
            {
                cbbThang.Items.Add(i);
            }

            for (int j = 2000; j <= 2012; j++)
            {
                cbbNam.Items.Add(j);
            }
        }
    }
}
